跳到主要内容

如何在 Node-RED 中使用 ChatGPT

This deep dive demonstrates how to use ChatGPT with Node‑RED.


需要注意的事项

  • All Block Outputs contain all the info that comes out once an image is triggered.

All Block Output node

  • Copy the debug output from the All Block Outputs.

Copy the All Block Outputs debug value

All Block Outputs

This node outputs data after each capture made by the camera and containing all AI block data. The data is in the form of a JSON object. The data includes the following:

Payload FieldTypeDescription
payload.capture_idinteger该捕获的捕获 ID
payload.recipe_idinteger该配方的 recipe_id
payload.camera_idstring本摄像头的唯一字符串标识符
payload.inspection_idinteger一个自增的 16 位整数,在每次检验时增加
payload.inspection_timestring该检验的 ISO 8601 格式时间戳
payload.image_urlstring捕获图像的 HTTP URL(jpg)
payload.alignment.successboolean对齐部分是否成功
payload.alignment.center_location_xinteger对齐部分的中心位置 X 坐标
payload.alignment.center_location_yinteger对齐部分的中心位置 Y 坐标
payload.alignment.confidencefloat (0-1)对齐置信度(0-1)

ChatGPT/Gemini/Copilot

  • Enter the prompt: “Here is the Input I have from Node Red : Insert the copied value here. enter prompt when you want it to fail and return msg.payload in boolean True or False”

ChatGPT Prompt Screen

Example

  • Here we have taught the AI to look for holes in the mounting plate.

Example annotation of mounting plate

  • Copy the values from the Node-RED debug block and paste it in ChatGPT with the following example prompt.
    • “Here is the Input I have from Node Red : Insert the copied value here. I want the camera to fail if there are less than 11 holes and return msg.payload in boolean True or False”

Example prompt

  • Take a look at the function block and read the comments on the logic.
  • See if it's doing the right thing (what was asked of it), and if so, copy the code it gives you.
  • Get a function node from the nodes and connect it to the Inspection Pass/Fail block.

Example of function block added to flow

Example ChatGPT window with function node code

  • Copy the code in the function block, make sure all the nodes are connected correctly and click 部署.

Example screenshot showing number of blobs

Example Edit function node window

Deploy button